package com.peng.config;

import com.peng.service.ChatAssistant;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
public class ChatLanguageModelConfig {
    //配置通义千问模型
    /*@Bean
    public ChatLanguageModel chatLanguageModel(){
        return
            OpenAiChatModel.builder()
                    .apiKey(System.getenv("DASH_SCOPE_API_KEY"))
                    .modelName("qwen-turbo")
                    .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
            .build();
    }/*/

    //配置DeepSeek模型
    @Bean
    public ChatLanguageModel chatLanguageModel() {
        return
                OpenAiChatModel.builder()
                        .apiKey(System.getenv("DEEPSEEK_API_KEY"))
                        //v3版本
                        .modelName("deepseek-chat")
                        //R1版本
                        //.modelName("deepseek-reasoner")
                        .baseUrl("https://api.deepseek.com/v1")
                        .build();
    }

    // 你使用第2种类，
    // 用 高阶API AiService 加原有的接口封装到你自己的接口上ChatAssistant
    @Bean
    public ChatAssistant chatAssistant(ChatLanguageModel chatLanguageModel) {
        return AiServices.create(ChatAssistant.class, chatLanguageModel);
    }
}